#ifndef _huff_h_
#define _huff_h_

#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>

#define BUFFER_SIZE 1024
#define NaB 257

typedef struct{
  int value;
  unsigned long prob;
  unsigned int length;
  struct Node *left;
  struct Node *right;
  struct Node *next;
} Node;

typedef struct{
  char value;
  unsigned short pos;
  struct Element* next;
} Element;

int huffencode(unsigned char* dst, unsigned char* src, int length);
int huffdecode(unsigned char* dst, unsigned char* src);
int setcodes(Node *root, int l, int code, unsigned char* dst, int pos, int* dstloc);
Node* findcode(Node *root, char c);

#endif
